﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Exhibitions : System.Web.UI.Page
{
    PagedDataSource objPds = new PagedDataSource();

    ExhibitionDAO exhDAO = new ExhibitionDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        MasterPage master = this.Master as MasterPage;
        master.BodyId = "exhibition";
        dtlUpcomingExhibition.DataSource = exhDAO.GetUpcoming();
        dtlUpcomingExhibition.DataBind();
        if (dtlUpcomingExhibition.Items.Count > 0)
        {
            lblUpcoming.Visible = false;
        }

        dtlOngoing.DataSource = exhDAO.GetOngoing();
        dtlOngoing.DataBind();
        if (dtlOngoing.Items.Count > 0)
        {
            lblOngoing.Visible = false;
        }

        ItemsGet();
    }

    public void ItemsGet()
    {
        IList<ExhibitionInfo> exhList = exhDAO.GetComplete();

        objPds = new PagedDataSource();
        objPds.DataSource = exhList;
        objPds.AllowPaging = true;
        objPds.PageSize = 3;

        try
        {
            objPds.CurrentPageIndex = Int32.Parse(Request["Page"].ToString());
        }
        catch (Exception ex)
        {
            objPds.CurrentPageIndex = 0;
        }

        lblCurrentPage.Text = "Page: " + (objPds.CurrentPageIndex + 1).ToString() + " of "
            + objPds.PageCount.ToString();



        cmdPrev.Enabled = !objPds.IsFirstPage;
        cmdNext.Enabled = !objPds.IsLastPage;

        dtlComplete.DataSource = objPds;
        dtlComplete.DataBind();




     //   dtlComplete.DataSource = exhDAO.GetComplete();
     //   dtlComplete.DataBind();

    }

    protected void cmdPrev_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (objPds.CurrentPageIndex - 1));
    }
    protected void cmdNext_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (objPds.CurrentPageIndex + 1));
    }
    protected void btn_AllExhibitions_Click(object sender, EventArgs e)
    {
        pnlComplete.Visible = true;
        pnlOngoing.Visible = true;
        pnlUpcoming.Visible = true;
    }
    protected void btn_OngoingExhibitions_Click(object sender, EventArgs e)
    {
        pnlOngoing.Visible = true;
        pnlComplete.Visible = false;
        pnlUpcoming.Visible = false;
    }
    protected void btn_UpcomingExhibitions_Click(object sender, EventArgs e)
    {
        pnlUpcoming.Visible = true;
        pnlComplete.Visible = false;
        pnlOngoing.Visible = false;
    }
    protected void btn_CompletedExhibitions_Click(object sender, EventArgs e)
    {
        pnlComplete.Visible = true;
        pnlOngoing.Visible = false;
        pnlUpcoming.Visible = false;
    }
}